﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CF.Data.Entity.FrmMemberEntity;

namespace CF.Member.DAL.Badges
{
    public class BadgeFactory
    {
        private const string NameSpace = "CF.Member.DAL.Badges.";

        public static IBadge GetBadgeObject(int bid)
        {
            IBadge ib = null;
            using (caifendbEntities context = new caifendbEntities())
            {
                FM_BadgeConfig bdcfg = context.FM_BadgeConfig.FirstOrDefault(c => c.BID == bid);
                if (bdcfg != null)
                {

                    Type type = Type.GetType(NameSpace + bdcfg.CheckMethod, false, true);
                    ib = (IBadge)Activator.CreateInstance(type);
                }
            }
            return ib;
        }
    }
}
